<%@ page import="com.es.bean.Student" %>
<%@ page import="java.util.List" %><%--
  Created by IntelliJ IDEA.
  User: Lenovo
  Date: 2022-04-25
  Time: 11:47
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>学生信息管理</title>

    <script>
        window.onload=function (){
            let msg = "<%=session.getAttribute("msg")%>";
            if(msg != "null"){
                alert(msg);
            }
            <%
                //删除属性
                session.removeAttribute("msg");
            %>
        }
    </script>
    <style>
        #app{
            width: 800px;
            margin: 0px auto;
        }
        .evenLine{
            background-color: beige;
        }
        .oddLine{
            background-color: aquamarine;
        }
        th{
            background-color: cornflowerblue;
            color: white;
            font-weight: bold;
        }
    </style>
</head>
<body>
    <div id="app">
        <h3>学生信息管理系统</h3>
        <span style="float: right">
        <a href="reg.html">添加</a>
    </span>
        <table width="100%">
            <tr>
                <th>学号</th>
                <th>姓名</th>
                <th>年龄</th>
                <th>性别</th>
                <th>地址</th>
                <th>电话</th>
                <th>操作</th>
            </tr>

                <%
                List<Student> list = (List<Student>) request.getAttribute("list");
                String className = "oddLine";
                int count = 0;
                for (Student stu: list){
                    count++;
                    if(count%2 == 0){
                        className = "oddLine";
                    }else{
                        className = "evenLine";
                    }

             %>
                <tr class="<%=className%>">
                    <td>
                        <% out.println(stu.getId());%>
                    </td>
                    <td><%=stu.getName()%></td>
                    <td><%=stu.getAge()%></td>
                    <td><%=stu.getSex()%></td>
                    <td><%=stu.getAddress()%></td>
                    <td><%=stu.getTelephone()%></td>
                    <td><a href="toUpdate?id=<%=stu.getId()%>">修改</a> &nbsp;&nbsp; <a href="delete?id=<%=stu.getId()%>">删除</a></td>
                </tr>
            <%
                }
            %>
        </table>
    </div>

</body>
</html>
